package com.zonta.finance.admin.controller;

import com.zonta.finance.common.dto.ApiResponse;
import com.zonta.finance.domain.form.GenerateMpRegCodeForm;
import com.zonta.finance.domain.form.PhoneRegisterForm;
import com.zonta.finance.domain.vo.GenerateMpRegCodeVo;
import com.zonta.finance.serivce.IMemberRegisterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;

import org.springframework.web.bind.annotation.*;

@Api(tags = "用户登录接口")
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/reg")
public class RegisterController {
    private final IMemberRegisterService registerService;
    @ApiOperation("手机号注册")
    @PostMapping("/phoneReg")
    public ApiResponse<Long> phoneRegister(@Validated @RequestBody PhoneRegisterForm form){
        return ApiResponse.success(registerService.phoneRegister(form));
    }


    @ApiOperation(value = "生成微信公众号二维码（关注注册）")
    @GetMapping(value = "/generateMpRegCode")
    public ApiResponse<GenerateMpRegCodeVo> generateMpRegCode(@Validated @ModelAttribute GenerateMpRegCodeForm form){
        GenerateMpRegCodeVo result = registerService.generateMpRegCode(form.getClientId());
        return ApiResponse.success(result);
    }
}
